//
//  SelectCurrency.swift
//  LOTR Converter
//
//  Created by li on 2025/4/2.
//
import SwiftUI

struct SelectCurrency: View {
    @Environment(\.dismiss) var dismiss
    
    @Binding var topCurrency:Currency
    @Binding var bottomRurrency:Currency
    var body : some View{
        ZStack{
            //背景图
            Image(.parchment)
                .resizable()
                .ignoresSafeArea()
                .background(.brown)
            VStack{
                //文本
                Text("选择你想消耗的货币")
                    .fontWeight(.bold)
                //货币图标
//                CurrencyIcon(text: "铜便士", icon: .copperpenny)
                IconGrid(currency: $topCurrency)
                //文本
                Text("选择你想兑换的货币")
                    .fontWeight(.bold)
                    .padding(.top)
                //货币图标
                IconGrid(currency: $bottomRurrency)
                //按钮
                Button("完成"){
                    dismiss()
                }
                .buttonStyle(.borderedProminent)
                .tint(.brown.mix(with: .black, by: 0.2))
                .font(.largeTitle)
                .padding()
                .foregroundStyle(.white)
            }
            .padding()
            .multilineTextAlignment(.center)
            .foregroundStyle(.black)
        }
    }

}

#Preview{
    @Previewable @State var topCurrency:Currency = .sliverPenny
    @Previewable @State var bottomCurrency:Currency = .goldPenny
    
    SelectCurrency(topCurrency: $topCurrency, bottomRurrency: $bottomCurrency)
}
